﻿using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;
using Pay.Core;
using Pay.DTO.card;

namespace Pay.Service.AutoMapper {

    public class CardMapper : IStartupDto {
        private IMapperConfigurationExpression _cfg;
        public CardMapper(IMapperConfigurationExpression cfg) {
            _cfg = cfg;
        }
        public void Execute() {
            Create();
        }
        protected virtual void Create() {
            _cfg.CreateMap<CardApply, card_apply>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.order_no, src => src.MapFrom(c => c.OrderNo))
                .ForMember(dest => dest.merchant_id, src => src.MapFrom(c => c.MerchantId))
                .ForMember(dest => dest.bind_id, src => src.MapFrom(c => c.BindId))
                .ForMember(dest => dest.name, src => src.MapFrom(c => c.Name))
                .ForMember(dest => dest.mobile, src => src.MapFrom(c => c.Mobile))
                .ForMember(dest => dest.id_card, src => src.MapFrom(c => c.IdCard))
                .ForMember(dest => dest.search_url, src => src.MapFrom(c => c.SearchUrl))
                .ForMember(dest => dest.notify, src => src.MapFrom(c => c.Notify))
                .ForMember(dest => dest.status, src => src.MapFrom(c => c.Status))
                .ForMember(dest => dest.profit, src => src.MapFrom(c => c.Profit))
                .ForMember(dest => dest.pay_id, src => src.MapFrom(c => c.PayId))
                .ForMember(dest => dest.order_time, src => src.MapFrom(c => c.OrderTime.ToDateTime()))
                .ForMember(dest => dest.bank_name, src => src.MapFrom(c => c.BankName))
                .ForMember(dest => dest.merchant, src => src.MapFrom(c => c.Merchant))
                .ForMember(dest => dest.binder, src => src.MapFrom(c => c.Binder))
                .ForMember(dest => dest.pay_info, src => src.MapFrom(c => c.PayInfo));
        }
    }
}
